<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesResources;

class Controller extends BaseController
{
    use AuthorizesRequests, AuthorizesResources, DispatchesJobs, ValidatesRequests;

    public static $_RESPONSE_CODE_SUCCESS = 1;
    public static $_RESPONSE_CODE_WARNING = 2;
    public static $_RESPONSE_CODE_FAIL = 0;

    function go($message, $result)
    {
        return json_encode(array(
            'code' => Controller::$_RESPONSE_CODE_SUCCESS,
            'message' => $message,
            'result' => $result
        ));
    }

    public function warn($message)
    {
        return json_encode(array(
            'code' => Controller::$_RESPONSE_CODE_WARNING,
            'message'=> $message
        ));
    }

    function stop($message)
    {
        return json_encode(array(
            'code' => Controller::$_RESPONSE_CODE_FAIL,
            'message' => $message
        ));
    }
}
